home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: utilFuncs.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:03 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "ess.h"
- #include "checking.h"
- #include "sysdefs.h"
- #include "trace.h"
- #include "error.h"
- #include "io.h"
- #include "list.h"
- #include "tid.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "latch.h"
- #include "bf.h"
- #include "volume.h"
- #include "pool.h"
- #include "server_util_funcs.h"
- #include "thread_globals.h"
- #include "disk_globals.h"
- #include "io_globals.h"
- #include "queue_consist.h"
- #include "disk_funcs.h"
- #include "io_extfuncs.h"
-
- #ifdef DEBUG
- void
- checkMalloc()
- {
- #ifdef JUNK
- static BOOL first = TRUE;
- static char *prev = NULL;
- char *current;
- current = (char *)sbrk(0);
- if(current != prev) {
- if(!first) {
- TRPRINT(TR_SHM, TR_LEVEL_1, ("Gained %d bytes!", current-prev));
- }
- }
- prev = current;
- first = FALSE;
- #endif JUNK
- }
- #endif DEBUG
-
- /*
- * MonDump(BOOL, volRec)
- * the 1st argument tells whether or not to dump the server process.
- * the 2nd argument has 3 possible semantics:
- * if null
- * if environment variable PROFDIR is set, do all disk processes
- * else don't bother with disk processes
- * else points to volume to kick
- */
- #ifdef PROFIL
- BEGIN_EXTERNC
- extern void monitor(int);
- extern void moncontrol(int);
- END_EXTERNC
-
- static BOOL
- ifOpenDoDump(
- VOLREC *volRec,
- DISKMSG *diskmessage,
- int *errloc
- )
- {
- int error = 0;
-
- SM_ASSERT(LEVEL_1, (volRec->volflags & VOL_OPEN) );
-
- if(volRec->diskrwPid) {
- if(callDisk(volRec, diskmessage))
- error = Active->errno;
- }
- if(error)
- *errloc = error;
- return FALSE;
- }
- #endif PROFIL
-
- int
- MonDump (
- BOOL unused1,
- VOLREC *unused2
- )
- {
- #ifdef PROFIL
- DISKMSG *diskmessage;
- int error;
-
- /* All this is under control of -DPROFIL so that
- * one can make a version of the server that
- * doesn't require the -p option (to get monstartup, etc
- * linked in).
- * The idea is that you compile with -p -DPROFIL or with
- * neither.
- */
-
-
- if(unused1) {
- /*
- * cease monitoring for the moment, and write the
- * mon.out file
- */
- monitor(0);
- /*
- * resume, using the original buffer
- */
- moncontrol(1);
- }
-
- /*
- * Now tell diskrw(s) to do the same...
- */
- SM_ASSERT(LEVEL_1, Active!=NULL);
- diskmessage = Active->diskMessage;
- diskmessage->header.type = DUMP_MON;
-
- if(unused2) {
- ifOpenDoDump(unused2, diskmessage, &error);
- } else if(HasProfDir) {
- ForEachVolume(2, ifOpenDoDump, diskmessage, &error, 0);
- }
- return error;
- #else PROFIL
- return esmNOTIMPLEMENTED;
- #endif PROFIL
- }
-
-
- void
- DumpCore ()
- {
- fprintf(stderr, "SERVER %d aborting; creating core file...\n", getpid());
- abort();
- }
-
-
- #ifdef DEBUG
- #include "distr.h"
- #include "distr_globals.h"
-
- int
- DebugSetVar(int var, int value)
- {
- switch(var) {
- case 0:
- break;
- case 1:
- DebugDistrVote = value;
- break;
- case 2:
- DebugCrashLoc = value;
- break;
- default:
- fprintf(sm_ErrorStream, "Unknown debug variable %d", var);
- return esmFAILURE;
- }
- return esmNOERROR;
- }
- int
- DebugGetVar(int var, int *value)
- {
- switch(var) {
- case 0:
- break;
- case 1:
- *value = DebugDistrVote;
- break;
- case 2:
- *value = DebugCrashLoc;
- break;
- default:
- return esmFAILURE;
- }
- return esmNOERROR;
- }
- #endif DEBUG
-